home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Pascal V7.0 / INTRFACE.ZIP / DIALOGS.INT < prev    next >
Encoding:
Text File  |  1992-10-30  |  13.7 KB  |  529 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal Version 7.0                        }
  5. {       Turbo Vision Unit                               }
  6. {                                                       }
  7. {       Copyright (c) 1991,92 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Dialogs;
  12.  
  13. {$O+,F+,X+,I-,S-}
  14.  
  15. interface
  16.  
  17. uses Objects, Drivers, Views, Validate;
  18.  
  19. const
  20.  
  21. { Color palettes }
  22.  
  23.   CGrayDialog    = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
  24.                    #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
  25.   CBlueDialog    = #64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79 +
  26.                    #80#81#82#83#84#85#86#87#88#89#90#91#92#92#94#95;
  27.   CCyanDialog    = #96#97#98#99#100#101#102#103#104#105#106#107#108 +
  28.                    #109#110#111#112#113#114#115#116#117#118#119#120 +
  29.                    #121#122#123#124#125#126#127;
  30.  
  31.   CDialog        = CGrayDialog;
  32.  
  33.   CStaticText    = #6;
  34.   CLabel         = #7#8#9#9;
  35.   CButton        = #10#11#12#13#14#14#14#15;
  36.   CCluster       = #16#17#18#18#31;
  37.   CInputLine     = #19#19#20#21;
  38.   CHistory       = #22#23;
  39.   CHistoryWindow = #19#19#21#24#25#19#20;
  40.   CHistoryViewer = #6#6#7#6#6;
  41.  
  42. { TDialog palette entires }
  43.  
  44.   dpBlueDialog = 1;
  45.   dpCyanDialog = 2;
  46.   dpGrayDialog = 3;
  47.  
  48. { TButton flags }
  49.  
  50.   bfNormal    = $00;
  51.   bfDefault   = $01;
  52.   bfLeftJust  = $02;
  53.   bfBroadcast = $04;
  54.  
  55. { TMultiCheckboxes flags }
  56. { hiword = number of bits }
  57. { loword = bit mask }
  58.  
  59.   cfOneBit       = $0101;
  60.   cfTwoBits      = $0203;
  61.   cfFourBits     = $040F;
  62.   cfEightBits    = $08FF;
  63.  
  64. type
  65.  
  66. { TDialog object }
  67.  
  68.   { Palette layout }
  69.   {  1 = Frame passive }
  70.   {  2 = Frame active }
  71.   {  3 = Frame icon }
  72.   {  4 = ScrollBar page area }
  73.   {  5 = ScrollBar controls }
  74.   {  6 = StaticText }
  75.   {  7 = Label normal }
  76.   {  8 = Label selected }
  77.   {  9 = Label shortcut }
  78.   { 10 = Button normal }
  79.   { 11 = Button default }
  80.   { 12 = Button selected }
  81.   { 13 = Button disabled }
  82.   { 14 = Button shortcut }
  83.   { 15 = Button shadow }
  84.   { 16 = Cluster normal }
  85.   { 17 = Cluster selected }
  86.   { 18 = Cluster shortcut }
  87.   { 19 = InputLine normal text }
  88.   { 20 = InputLine selected text }
  89.   { 21 = InputLine arrows }
  90.   { 22 = History arrow }
  91.   { 23 = History sides }
  92.   { 24 = HistoryWindow scrollbar page area }
  93.   { 25 = HistoryWindow scrollbar controls }
  94.   { 26 = ListViewer normal }
  95.   { 27 = ListViewer focused }
  96.   { 28 = ListViewer selected }
  97.   { 29 = ListViewer divider }
  98.   { 30 = InfoPane }
  99.   { 31 = Reserved }
  100.   { 32 = Reserved }
  101.  
  102.   PDialog = ^TDialog;
  103.   TDialog = object(TWindow)
  104.     constructor Init(var Bounds: TRect; ATitle: TTitleStr);
  105.     constructor Load(var S: TStream);
  106.     function GetPalette: PPalette; virtual;
  107.     procedure HandleEvent(var Event: TEvent); virtual;
  108.     function Valid(Command: Word): Boolean; virtual;
  109.   end;
  110.  
  111. { TSItem }
  112.  
  113.   PSItem = ^TSItem;
  114.   TSItem = record
  115.     Value: PString;
  116.     Next: PSItem;
  117.   end;
  118.  
  119. { TInputLine object }
  120.  
  121.   { Palette layout }
  122.   { 1 = Passive }
  123.   { 2 = Active }
  124.   { 3 = Selected }
  125.   { 4 = Arrows }
  126.  
  127.   PInputLine = ^TInputLine;
  128.   TInputLine = object(TView)
  129.     Data: PString;
  130.     MaxLen: Integer;
  131.     CurPos: Integer;
  132.     FirstPos: Integer;
  133.     SelStart: Integer;
  134.     SelEnd: Integer;
  135.     Validator: PValidator;
  136.     constructor Init(var Bounds: TRect; AMaxLen: Integer);
  137.     constructor Load(var S: TStream);
  138.     destructor Done; virtual;
  139.     function DataSize: Word; virtual;
  140.     procedure Draw; virtual;
  141.     procedure GetData(var Rec); virtual;
  142.     function GetPalette: PPalette; virtual;
  143.     procedure HandleEvent(var Event: TEvent); virtual;
  144.     procedure SelectAll(Enable: Boolean);
  145.     procedure SetData(var Rec); virtual;
  146.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  147.     procedure SetValidator(AValid: PValidator);
  148.     procedure Store(var S: TStream);
  149.     function Valid(Command: Word): Boolean; virtual;
  150.   end;
  151.  
  152. { TButton object }
  153.  
  154.   { Palette layout }
  155.   { 1 = Normal text }
  156.   { 2 = Default text }
  157.   { 3 = Selected text }
  158.   { 4 = Disabled text }
  159.   { 5 = Normal shortcut }
  160.   { 6 = Default shortcut }
  161.   { 7 = Selected shortcut }
  162.   { 8 = Shadow }
  163.  
  164.   PButton = ^TButton;
  165.   TButton = object(TView)
  166.     Title: PString;
  167.     Command: Word;
  168.     Flags: Byte;
  169.     AmDefault: Boolean;
  170.     constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  171.       AFlags: Word);
  172.     constructor Load(var S: TStream);
  173.     destructor Done; virtual;
  174.     procedure Draw; virtual;
  175.     procedure DrawState(Down: Boolean);
  176.     function GetPalette: PPalette; virtual;
  177.     procedure HandleEvent(var Event: TEvent); virtual;
  178.     procedure MakeDefault(Enable: Boolean);
  179.     procedure Press; virtual;
  180.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  181.     procedure Store(var S: TStream);
  182.   end;
  183.  
  184. { TCluster }
  185.  
  186.   { Palette layout }
  187.   { 1 = Normal text }
  188.   { 2 = Selected text }
  189.   { 3 = Normal shortcut }
  190.   { 4 = Selected shortcut }
  191.   { 5 = Disabled text }
  192.  
  193.   PCluster = ^TCluster;
  194.   TCluster = object(TView)
  195.     Value: LongInt;
  196.     Sel: Integer;
  197.     EnableMask: LongInt;
  198.     Strings: TStringCollection;
  199.     constructor Init(var Bounds: TRect; AStrings: PSItem);
  200.     constructor Load(var S: TStream);
  201.     destructor Done; virtual;
  202.     function ButtonState(Item: Integer): Boolean;
  203.     function DataSize: Word; virtual;
  204.     procedure DrawBox(const Icon: String; Marker: Char);
  205.     procedure DrawMultiBox(const Icon, Marker: String);
  206.     procedure GetData(var Rec); virtual;
  207.     function GetHelpCtx: Word; virtual;
  208.     function GetPalette: PPalette; virtual;
  209.     procedure HandleEvent(var Event: TEvent); virtual;
  210.     function Mark(Item: Integer): Boolean; virtual;
  211.     function MultiMark(Item: Integer): Byte; virtual;
  212.     procedure Press(Item: Integer); virtual;
  213.     procedure MovedTo(Item: Integer); virtual;
  214.     procedure SetButtonState(AMask: Longint; Enable: Boolean);
  215.     procedure SetData(var Rec); virtual;
  216.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  217.     procedure Store(var S: TStream);
  218.   end;
  219.  
  220. { TRadioButtons }
  221.  
  222.   { Palette layout }
  223.   { 1 = Normal text }
  224.   { 2 = Selected text }
  225.   { 3 = Normal shortcut }
  226.   { 4 = Selected shortcut }
  227.  
  228.   PRadioButtons = ^TRadioButtons;
  229.   TRadioButtons = object(TCluster)
  230.     procedure Draw; virtual;
  231.     function Mark(Item: Integer): Boolean; virtual;
  232.     procedure MovedTo(Item: Integer); virtual;
  233.     procedure Press(Item: Integer); virtual;
  234.     procedure SetData(var Rec); virtual;
  235.   end;
  236.  
  237. { TCheckBoxes }
  238.  
  239.   { Palette layout }
  240.   { 1 = Normal text }
  241.   { 2 = Selected text }
  242.   { 3 = Normal shortcut }
  243.   { 4 = Selected shortcut }
  244.  
  245.   PCheckBoxes = ^TCheckBoxes;
  246.   TCheckBoxes = object(TCluster)
  247.     procedure Draw; virtual;
  248.     function Mark(Item: Integer): Boolean; virtual;
  249.     procedure Press(Item: Integer); virtual;
  250.   end;
  251.  
  252. { TMultiCheckBoxes }
  253.  
  254.   { Palette layout }
  255.   { 1 = Normal text }
  256.   { 2 = Selected text }
  257.   { 3 = Normal shortcut }
  258.   { 4 = Selected shortcut }
  259.  
  260.   PMultiCheckBoxes = ^TMultiCheckBoxes;
  261.   TMultiCheckBoxes = object(TCluster)
  262.     SelRange: Byte;
  263.     Flags: Word;
  264.     States: PString;
  265.     constructor Init(var Bounds: TRect; AStrings: PSItem;
  266.       ASelRange: Byte; AFlags: Word; const AStates: String);
  267.     constructor Load(var S: TStream);
  268.     destructor Done; virtual;
  269.     function DataSize: Word; virtual;
  270.     procedure Draw; virtual;
  271.     procedure GetData(var Rec); virtual;
  272.     function MultiMark(Item: Integer): Byte; virtual;
  273.     procedure Press(Item: Integer); virtual;
  274.     procedure SetData(var Rec); virtual;
  275.     procedure Store(var S: TStream);
  276.   end;
  277.  
  278. { TListBox }
  279.  
  280.   { Palette layout }
  281.   { 1 = Active }
  282.   { 2 = Inactive }
  283.   { 3 = Focused }
  284.   { 4 = Selected }
  285.   { 5 = Divider }
  286.  
  287.   PListBox = ^TListBox;
  288.   TListBox = object(TListViewer)
  289.     List: PCollection;
  290.     constructor Init(var Bounds: TRect; ANumCols: Word;
  291.       AScrollBar: PScrollBar);
  292.     constructor Load(var S: TStream);
  293.     function DataSize: Word; virtual;
  294.     procedure GetData(var Rec); virtual;
  295.     function GetText(Item: Integer; MaxLen: Integer): String; virtual;
  296.     procedure NewList(AList: PCollection); virtual;
  297.     procedure SetData(var Rec); virtual;
  298.     procedure Store(var S: TStream);
  299.   end;
  300.  
  301. { TStaticText }
  302.  
  303.   { Palette layout }
  304.   { 1 = Text }
  305.  
  306.   PStaticText = ^TStaticText;
  307.   TStaticText = object(TView)
  308.     Text: PString;
  309.     constructor Init(var Bounds: TRect; const AText: String);
  310.     constructor Load(var S: TStream);
  311.     destructor Done; virtual;
  312.     procedure Draw; virtual;
  313.     function GetPalette: PPalette; virtual;
  314.     procedure GetText(var S: String); virtual;
  315.     procedure Store(var S: TStream);
  316.   end;
  317.  
  318. { TParamText }
  319.  
  320.   { Palette layout }
  321.   { 1 = Text }
  322.  
  323.   PParamText = ^TParamText;
  324.   TParamText = object(TStaticText)
  325.     ParamCount: Integer;
  326.     ParamList: Pointer;
  327.     constructor Init(var Bounds: TRect; const AText: String;
  328.       AParamCount: Integer);
  329.     constructor Load(var S: TStream);
  330.     function DataSize: Word; virtual;
  331.     procedure GetText(var S: String); virtual;
  332.     procedure SetData(var Rec); virtual;
  333.     procedure Store(var S: TStream);
  334.   end;
  335.  
  336. { TLabel }
  337.  
  338.   { Palette layout }
  339.   { 1 = Normal text }
  340.   { 2 = Selected text }
  341.   { 3 = Normal shortcut }
  342.   { 4 = Selected shortcut }
  343.  
  344.   PLabel = ^TLabel;
  345.   TLabel = object(TStaticText)
  346.     Link: PView;
  347.     Light: Boolean;
  348.     constructor Init(var Bounds: TRect; const AText: String; ALink: PView);
  349.     constructor Load(var S: TStream);
  350.     procedure Draw; virtual;
  351.     function GetPalette: PPalette; virtual;
  352.     procedure HandleEvent(var Event: TEvent); virtual;
  353.     procedure Store(var S: TStream);
  354.   end;
  355.  
  356. { THistoryViewer }
  357.  
  358.   { Palette layout }
  359.   { 1 = Active }
  360.   { 2 = Inactive }
  361.   { 3 = Focused }
  362.   { 4 = Selected }
  363.   { 5 = Divider }
  364.  
  365.   PHistoryViewer = ^THistoryViewer;
  366.   THistoryViewer = object(TListViewer)
  367.     HistoryId: Word;
  368.     constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  369.       AHistoryId: Word);
  370.     function GetPalette: PPalette; virtual;
  371.     function GetText(Item: Integer; MaxLen: Integer): String; virtual;
  372.     procedure HandleEvent(var Event: TEvent); virtual;
  373.     function HistoryWidth: Integer;
  374.   end;
  375.  
  376. { THistoryWindow }
  377.  
  378.   { Palette layout }
  379.   { 1 = Frame passive }
  380.   { 2 = Frame active }
  381.   { 3 = Frame icon }
  382.   { 4 = ScrollBar page area }
  383.   { 5 = ScrollBar controls }
  384.   { 6 = HistoryViewer normal text }
  385.   { 7 = HistoryViewer selected text }
  386.  
  387.   PHistoryWindow = ^THistoryWindow;
  388.   THistoryWindow = object(TWindow)
  389.     Viewer: PListViewer;
  390.     constructor Init(var Bounds: TRect; HistoryId: Word);
  391.     function GetPalette: PPalette; virtual;
  392.     function GetSelection: String; virtual;
  393.     procedure InitViewer(HistoryId: Word); virtual;
  394.   end;
  395.  
  396. { THistory }
  397.  
  398.   { Palette layout }
  399.   { 1 = Arrow }
  400.   { 2 = Sides }
  401.  
  402.   PHistory = ^THistory;
  403.   THistory = object(TView)
  404.     Link: PInputLine;
  405.     HistoryId: Word;
  406.     constructor Init(var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
  407.     constructor Load(var S: TStream);
  408.     procedure Draw; virtual;
  409.     function GetPalette: PPalette; virtual;
  410.     procedure HandleEvent(var Event: TEvent); virtual;
  411.     function InitHistoryWindow(var Bounds: TRect): PHistoryWindow; virtual;
  412.     procedure RecordHistory(const S: String); virtual;
  413.     procedure Store(var S: TStream);
  414.   end;
  415.  
  416. { SItem routines }
  417.  
  418. function NewSItem(const Str: String; ANext: PSItem): PSItem;
  419.  
  420. { Dialogs registration procedure }
  421.  
  422. procedure RegisterDialogs;
  423.  
  424. { Stream Registration Records }
  425.  
  426. const
  427.   RDialog: TStreamRec = (
  428.      ObjType: 10;
  429.      VmtLink: Ofs(TypeOf(TDialog)^);
  430.      Load:    @TDialog.Load;
  431.      Store:   @TDialog.Store
  432.   );
  433.  
  434. const
  435.   RInputLine: TStreamRec = (
  436.      ObjType: 11;
  437.      VmtLink: Ofs(TypeOf(TInputLine)^);
  438.      Load:    @TInputLine.Load;
  439.      Store:   @TInputLine.Store
  440.   );
  441.  
  442. const
  443.   RButton: TStreamRec = (
  444.      ObjType: 12;
  445.      VmtLink: Ofs(TypeOf(TButton)^);
  446.      Load:    @TButton.Load;
  447.      Store:   @TButton.Store
  448.   );
  449.  
  450. const
  451.   RCluster: TStreamRec = (
  452.      ObjType: 13;
  453.      VmtLink: Ofs(TypeOf(TCluster)^);
  454.      Load:    @TCluster.Load;
  455.      Store:   @TCluster.Store
  456.   );
  457.  
  458. const
  459.   RRadioButtons: TStreamRec = (
  460.      ObjType: 14;
  461.      VmtLink: Ofs(TypeOf(TRadioButtons)^);
  462.      Load:    @TRadioButtons.Load;
  463.      Store:   @TRadioButtons.Store
  464.   );
  465.  
  466. const
  467.   RCheckBoxes: TStreamRec = (
  468.      ObjType: 15;
  469.      VmtLink: Ofs(TypeOf(TCheckBoxes)^);
  470.      Load:    @TCheckBoxes.Load;
  471.      Store:   @TCheckBoxes.Store
  472.   );
  473.  
  474. const
  475.   RMultiCheckBoxes: TStreamRec = (
  476.      ObjType: 27;
  477.      VmtLink: Ofs(TypeOf(TMultiCheckBoxes)^);
  478.      Load:    @TMultiCheckBoxes.Load;
  479.      Store:   @TMultiCheckBoxes.Store
  480.   );
  481.  
  482. const
  483.   RListBox: TStreamRec = (
  484.      ObjType: 16;
  485.      VmtLink: Ofs(TypeOf(TListBox)^);
  486.      Load:    @TListBox.Load;
  487.      Store:   @TListBox.Store
  488.   );
  489.  
  490. const
  491.   RStaticText: TStreamRec = (
  492.      ObjType: 17;
  493.      VmtLink: Ofs(TypeOf(TStaticText)^);
  494.      Load:    @TStaticText.Load;
  495.      Store:   @TStaticText.Store
  496.   );
  497.  
  498. const
  499.   RLabel: TStreamRec = (
  500.      ObjType: 18;
  501.      VmtLink: Ofs(TypeOf(TLabel)^);
  502.      Load:    @TLabel.Load;
  503.      Store:   @TLabel.Store
  504.   );
  505.  
  506. const
  507.   RHistory: TStreamRec = (
  508.      ObjType: 19;
  509.      VmtLink: Ofs(TypeOf(THistory)^);
  510.      Load:    @THistory.Load;
  511.      Store:   @THistory.Store
  512.   );
  513.  
  514. const
  515.   RParamText: TStreamRec = (
  516.      ObjType: 20;
  517.      VmtLink: Ofs(TypeOf(TParamText)^);
  518.      Load:    @TParamText.Load;
  519.      Store:   @TParamText.Store
  520.   );
  521.  
  522. const
  523.  
  524. { Dialog broadcast commands }
  525.  
  526.   cmRecordHistory = 60;
  527.  
  528.  
  529.